export function numberFormatter (number) {
  if (typeof number !== 'number') {
    return '';
  }
  const numbers = number.toString().split('').reverse()
  const segs = []

  while (numbers.length) segs.push(numbers.splice(0, 3).join(''))

  return segs.join(',').split('').reverse().join('')
}

export const removeClass = (target, className) => {
  if (!target) return;
  target.classList.remove(className);
};

export const addClass = (target, className) => {
  if (!className) return;
  target.classList.add(className);
};

export const getStyle = (el, styleName) => {
  if (!el) return null;
  var computed = document.defaultView.getComputedStyle(el, '');
  return el.style[styleName] || computed ? computed[styleName] : null;
}